package com.ujiuye.service;
import com.ujiuye.dao.dao;
import com.ujiuye.pojo.studen;
import com.ujiuye.utils.pagetools;
import java.util.List;

public class service {
    dao dao= new dao();
    /**
     * 分页查询
     * @param currentPage
     * @param pageSize
     * @param search
     */
    public pagetools query(String currentPage, String pageSize, String search) {
        int cp = 1;
        if (currentPage!=null|"".equals(currentPage)){
            cp = Integer.parseInt(currentPage);
        }
        int ps = 6;
        if (pageSize!=null|"".equals(pageSize)){
            ps = Integer.parseInt(pageSize);
        }
        //select count(*) from student where sname like '%search%'
        int i = dao.queryall(search);

        pagetools pt = new pagetools(cp,ps,i);
        List<studen> list = dao.query(pt,search);
        pt.setStudentList(list);
        return pt;
    }
}
